﻿using Autofac;
using MgSoft.Import.Exchange.ExWebApi.Db.Daos;
using MgSoft.Import.Exchange.ExWebApi.Db.Dtos;
using MgSoft.Import.Exchange.ExWebApi.Db.Services;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Text;

namespace MgSoft.Import.Exchange.ExWebApi.Db
{
    public class DbTask : ExWebApiTask, IDbTask
    {
        private IDbTaskService dbTaskService;

        public DbTask(ILifetimeScope lifetimeScope)
        {
            dbTaskService = lifetimeScope.Resolve<IDbTaskService>();
        }

        public override void Do<TDto>(TDto exchangeDto)
        {
            var dto = exchangeDto as IDbExchangeDto;

            if(dto==null)
            {
                throw new ArgumentException("exchangeDto必须继承于IDbExchangeDto");
            }

            dbTaskService.Do(dto.GetDto_BillType(),dto.GetDto_BillTypeName(),dto);
        }
    }
}
